/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package aburakc.message;

import java.util.Calendar;
import java.util.Date;
import java.util.Random;

/**
 *
 * @author burak.costu
 */
public class GeneralMessage {
    public static final int GENERAL = 0;
    public static final int CONFIRM = 1;
    public static final int SMS = 2;

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final GeneralMessage other = (GeneralMessage) obj;
        if (this.messageId != other.messageId) {
            return false;
        }
        return true;
    }

    public int hashCode() {
        int hash = 7;
        hash = (int) (97 * hash + this.messageId);
        return hash;
    }
    public static final String SEPERATOR = "||";
    public static final String FINAL_SEPERATOR = "|&&|";
    Date date;
    private int messageType;
    private long messageId;

    public GeneralMessage(){
        
        setMessageId(getMessageId());
    }


    public static long generateId(){
        return System.currentTimeMillis();
    }
    /**
     * @return the messageId
     */
    public long getMessageId() {
        return messageId;
    }

    /**
     * @param messageId the messageId to set
     */
    public void setMessageId(long messageId) {
        this.messageId = messageId;
    }

    public String toNetworkMessage(){
        StringBuffer sb = new StringBuffer();
        sb.append(GENERAL);
        sb.append(SEPERATOR);
        sb.append(getMessageId());
        sb.append(FINAL_SEPERATOR);
        
        return sb.toString();
    }

}
